package com.logAndSignProvider.controller;

import com.alibaba.fastjson.JSON;
import com.logAndSignProvider.service.StoreService;
import entity.ResponseMessage;
import entity.Store;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * The type Store controller.
 */
@RestController
@RequestMapping("/store")
@CrossOrigin
public class StoreController {
    /**
     * The Store service.
     */
    @Autowired
    private StoreService storeService;

    /**
     * Select all string.
     *
     * @param store the store
     * @return the string
     */
    @RequestMapping("/selectAll")
    public String selectAll(@RequestBody Store store) {
        ResponseMessage msg = storeService.selectAll(store);
        return JSON.toJSONString(msg);
    }

    /**
     * Insert store string.
     *
     * @param store the store
     * @return the string
     */
    @RequestMapping("/insertStore")
    public String insertStore(@RequestBody Store store) {
        ResponseMessage insert = storeService.insert(store);
        return JSON.toJSONString(insert);
    }

    /**
     * Update store string.
     *
     * @param store the store
     * @return the string
     */
    @RequestMapping("/updateStore")
    public String updateStore(@RequestBody Store store) {
        ResponseMessage update = storeService.update(store);
        return JSON.toJSONString(update);
    }

    /**
     * Delete store string.
     *
     * @param id the id
     * @return the string
     */
    @RequestMapping("/deleteStore/{id}")
    public String deleteStore(@PathVariable("id") String id) {
        ResponseMessage delete = storeService.delete(id);
        return JSON.toJSONString(delete);
    }
}
